<?php

namespace App\Admin\Controllers;

use App\Models\CouponRecord;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use Encore\Admin\Controllers\AdminController;

class CouponRecordsController extends AdminController
{
    protected $title = '卡卷记录';
    
    protected function grid()
    {
        $grid = new Grid(new CouponRecord());
	
	    $grid->disableExport();
	    
	    $grid->column('user_id', '会员')->display(function () {
	    	return $this->user ? $this->user->nameText(true) : '';
	    });
	    $grid->column('coupon_id', '卡卷名称')->display(function () {
	    	return $this->coupon ? $this->coupon->name : '';
	    });

	    $grid->column('is_used', '使用状态')->display(function ($value) {
		    return $value ? _label('已使用', 'default') : _label('未使用', 'success');
	    });
	   
	    $grid->column('created_at', '创建时间')->display(function () {
	    	return $this->created_at->toDatetimeString();
	    });
	    $grid->column('destroy_at', '过期时间')->display(function () {
	    	return $this->destroy_at;
	    });
        return $grid;
    }
    
    
}
